﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             x:Class="Rio.Manager.Application.Views.BarCodeTabView"
             mc:Ignorable="d"
             d:DesignHeight="768"
             d:DesignWidth="1024">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Skins/BarCodeTabSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Path="BarCodeTab"
                 Source="{StaticResource Locator}" />
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <mvvmLightCommand:EventToCommand Command="{Binding InitializationCommand}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

        <!--General grid definition-->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition/>
        </Grid.RowDefinitions>

        <!--View title-->
        <TextBlock TextWrapping="Wrap"
                   Text="{Binding BarCodeTitleList}"
                   FontWeight="Bold"
                   Margin="10,10,0,10"/>

        <!--View informations-->
        <Grid Margin="20,0,20,20" 
              Grid.Row="2">

            <!--Grid information definition.-->
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--Button toolbar.-->
            <telerik:RadToolBar>
                <!--Add button toolbar-->
                <telerik:RadMenuItem Command="{Binding BarCodeCreateCommand}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Add.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding NewBarCode}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Activate button toolbar-->
                <telerik:RadMenuItem Command="{Binding BarCodeActivateDeactiveCommand}"
                                     IsEnabled="{Binding CanActivateBarCode, Mode=TwoWay}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Activate.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding ActivateBarCode}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Update button toolbar-->
                <telerik:RadMenuItem Command="{Binding BarCodeModifyCommand}"
                                     IsEnabled="{Binding CanUpdateBarCode, Mode=TwoWay}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Update.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding ModifyBarCode}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Delete button toolbar-->
                <telerik:RadMenuItem Command="{Binding BarCodeDeleteCommand}"
                                     IsEnabled="{Binding CanDeleteBarCode, Mode=TwoWay}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Delete.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding DeleteBarCode}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Refresh button toolbar-->
                <telerik:RadMenuItem Command="{Binding BarCodeRefreshCommand}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Refresh.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding RefreshBarCode}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>
            </telerik:RadToolBar>

            <!--Show barcode informations-->
            <!--Grid definition.-->
            <telerik:RadGridView x:Name="RadGridView_BarCode_Information"
                                 Grid.Row="1"
                                 ShowGroupPanel="False" 
                                 IsFilteringAllowed="True"
                                 ItemsSource="{Binding BarCodeInformationList, Mode=TwoWay}"
                                 RowIndicatorVisibility="Collapsed"
                                 IsReadOnly="True"
                                 AutoGenerateColumns="False"
                                 CanUserFreezeColumns="False"
                                 CanUserResizeColumns="False"
                                 SelectionMode="Extended"
                                 SelectionChanged="RadGridView_BarCode_Information_SelectionChanged"
                                 RowDetailsVisibilityChanged="RadGridView_BarCode_Information_RowDetailsVisibilityChanged">
                
            <!--General informations barcode.-->
            <telerik:RadGridView.Columns>
                <telerik:GridViewSelectColumn/>
                <telerik:GridViewToggleRowDetailsColumn/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeEnable, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding Enabled}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeParamCode, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding ParamCode}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeName, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeDescription, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding Description}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodePrefix, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding Prefix}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeType, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding TypeLabel}"/>
                <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeFunction, Source={StaticResource Locator}, Mode=OneWay}"
                                            DataMemberBinding="{Binding FunctionLabel}"/>
           </telerik:RadGridView.Columns>
                
                <!--Shows barcode informations.-->
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>

                        <!--RadTabControl definition-->
                        <telerik:RadTabControl x:Name="RadTabControl_BarCode_Seperator"
                                               BackgroundVisibility="Collapsed"
                                               Background="Transparent"
                                               Margin="0,10,0,10">

                            <!--Separator Document informations-->
                            <telerik:RadTabItem Header="{Binding BarCodeTab.RadTabItemHeaderSepDocument, Source={StaticResource Locator}, Mode=OneWay}"
                                                IsEnabled="{Binding BarCodeTab.RadTabItemSepDocumentIsEnabled, Source={StaticResource Locator}, Mode=TwoWay}"
                                                IsSelected="{Binding BarCodeTab.RadTabItemSepDocumentIsSelected, Source={StaticResource Locator}, Mode=TwoWay}">
                                <StackPanel Orientation="Vertical">
                                    <!--Item separator document title-->
                                    <TextBlock TextWrapping="Wrap"
                                               Text="{Binding BarCodeTab.SepDocItemList, Source={StaticResource Locator}, Mode=OneWay}"
                                               FontWeight="Bold"
                                               Margin="10,10,0,10" />
                                    <!--Grid View to show separator document barcode.-->
                                    <telerik:RadGridView x:Name="RadGridView_Separator_Document_BarCode"
                                                         ShowGroupPanel="False"
                                                         IsFilteringAllowed="True"
                                                         IsReadOnly="True"
                                                         ItemsSource="{Binding BarCodeSeparatorList, Mode=TwoWay}"
                                                         AutoGenerateColumns="False"
                                                         CanUserFreezeColumns="False"
                                                         CanUserResizeColumns="False">
                                        <!--Separator document barcode.-->
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentId, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding ParamCode}"/>
                                           <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentNatureName, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding NatureName}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentItemName, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding ItemName}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentPdfMerge, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding PdfMerge}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentDeleteBarCodePage, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding DeleteBarCodePage}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentManageError, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding ErrorManagment}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentInfLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding InfLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorDocumentSupLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding SupLimit}"/>
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
                                </StackPanel>
                            </telerik:RadTabItem>

                            <!--Separator Folder informations-->
                            <telerik:RadTabItem Header="{Binding BarCodeTab.RadTabItemHeaderSepFolder, Source={StaticResource Locator}, Mode=OneWay}" 
                                                IsEnabled="{Binding BarCodeTab.RadTabItemSepFolderIsEnabled, Source={StaticResource Locator}, Mode =TwoWay}"
                                                IsSelected="{Binding BarCodeTab.RadTabItemSepFolderIsSelected, Source={StaticResource Locator}, Mode =TwoWay}"> 

                                <StackPanel Orientation="Vertical">
                                    <!--Item separator folder title-->
                                    <TextBlock TextWrapping="Wrap"
                                               Text="{Binding BarCodeTab.SepFolderItemList, Source={StaticResource Locator}, Mode=OneWay}"
                                               FontWeight="Bold"
                                               Margin="10,10,0,10" />
                                    <!--Grid View to show separator folder barcode.-->
                                    <telerik:RadGridView x:Name="RadGridView_Separator_Folder_BarCode"
                                                         ShowGroupPanel="False"
                                                         IsFilteringAllowed="True"
                                                         IsReadOnly="True"
                                                         ItemsSource="{Binding BarCodeSeparatorList, Mode=TwoWay}"
                                                         AutoGenerateColumns="False"
                                                         CanUserFreezeColumns="False"
                                                         CanUserResizeColumns="False">
                                        <!--Separator folder barcode.-->
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderCorresp, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding CorrespondenceFolder}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderIndexname, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding UniqueIndexLabel}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderIndexStartChar, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding StartChar}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderIndexEndChar, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding EndChar}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderDocLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding DocLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderPageLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding PageLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderDocumentLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding DocumentLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderInfLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding InfLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderSupLimit, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding SupLimit}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderDeleteCAB, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding DeleteBarCodePage}"/>
                                            <telerik:GridViewDataColumn Header="{Binding BarCodeTab.HeaderBarCodeSeparatorFolderErrorManagment, Source={StaticResource Locator}, Mode=TwoWay}"
														                DataMemberBinding="{Binding ErrorManagment}"/>                                                           
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
                                </StackPanel>
                            </telerik:RadTabItem>
                        </telerik:RadTabControl>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
        </Grid>
        
        <telerik:RadBusyIndicator BusyContent=""
                                  IsBusy="{Binding BusyIndicator.IsBusy, Mode=OneWay}"
                                  Grid.RowSpan="2"
                                  d:IsHidden="True"/>
    </Grid>
</UserControl>
